<template>
  <div>
    <el-button @click="handleClickChangeContent" type="primary">修改</el-button>
    <br/><br/>
    <wangEditor :catchData="catchData" ref="editor" ></wangEditor>
  </div>
</template>
<script>
import wangEditor from '../../common/wangEditor'
export default {
  name: 'EventDescription',
  data () {
    return {
      editorContent: ''
    }
  },
  methods: {
    handleClickChangeContent () {
      let self = this
      let params = {}
      params.luckdrawcontent = this.editorContent
      this.axios.post('/Luckdraw/editagreement', self.qs.stringify(params)).then(res => {
        if (res.data.status === 1 || res.data.status === '1') {
          self.$message({
            message: '修改成功',
            type: 'success'
          })
          self.getList()
        }
      })
    },
    catchData (val) {
      this.editorContent = val
    },
    getList () {
      this.axios.get('/Luckdraw/agreement', {}).then(res => {
        if ((res.data.status === 1 || res.data.status === '1') && res.data.data) {
          this.$refs['editor'].setData(res.data.data.luckdrawcontent)
        }
      })
    }
  },
  mounted () {
    this.getList()
    // this.$refs['editor'].setData('<p>a</p><p><br>aaaaaaaaaaaaaaaaa</p>')
  },
  components: {
    wangEditor
  }
}
</script>
<style scoped>
@import "../../../assets/css/style.css";
</style>
